//
//  BHMenuBarView.m
//  Behing
//
//  Created by Lj on 2017/10/17.
//  Copyright © 2017年 lj. All rights reserved.
//

#import "BHMenuBarView.h"

@implementation BHMenuBarView

- (id)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self setUpUI];
    }
    return self;
}

- (void)setUpUI {
    UIButton *button = [[UIButton alloc]init];
    [button setTitle:@"项目筛选" forState:UIControlStateNormal];
    [button setImage:[UIImage imageNamed:@"icon_indication"] forState:UIControlStateNormal];
    button.titleLabel.font = BHFont_Size_15;
    [button setTitleColor:[UIColor colorWithHexString:@"#1ED4A6"] forState:UIControlStateNormal];
    CGSize titleSize = BH_TEXTSIZE(@"项目筛选", BHFont_Size_15);
    [button setImageEdgeInsets:UIEdgeInsetsMake(8, titleSize.width + 20, 8, 0)];
    [button setTitleEdgeInsets:UIEdgeInsetsMake(0, - titleSize.width - 10, 0, 0)];
    [button addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:button];
    [button mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self);
    }];
}

- (void)buttonClick:(UIButton *)sender {
    if (self.delegate && [self.delegate respondsToSelector:@selector(menuBarView:didSelect:selected:)]) {
        [self.delegate menuBarView:self didSelect:0 selected:sender.selected];
    }
    sender.selected = !sender.selected;
}

@end
